{% extends "business/customer.html" %}
{% block content %}
<div>
    <div class="row">
        <div class="col-md-4"><h5><strong>客户ID：{{ customer.id }}</strong></h5></div>
    </div>
    <br>

    <div class="row">
        <div class="col-md-4"><strong>客户名称：</strong>{{ customer.name }}</div>
        <div class="col-md-4"><strong>客户地址：</strong>{{ customer.address }}</div>
        <div class="col-md-4"><strong>客户行业：</strong>{{ customer.trade }}</div>
    </div>
    <br>

    <div class="row">
        <div class="col-md-4"><strong>联系人：</strong>{{ customer.contact }}</div>
        <div class="col-md-4"><strong>联系电话：</strong>{{ customer.telenumber }}</div>
        <div class="col-md-4"><strong>联系邮箱：</strong>{{ customer.email }}</div>
    </div>
    <br>

    <div class="row">
        <div class="col-md-4"><strong>销售：</strong>{{ customer.saler }}</div>
        <div class="col-md-4"><strong>客户级别：</strong>{{ customer.level }}</div>
        <div class="col-md-4">
            <label for="content">备注信息：</label>
            <textarea id="content" class="form-control" rows="5" cols="40">
{{ customer.remark }}
            </textarea>
         </div>
    </div>
    <br>

    <div class="row">
        <div class="col-md-8"> 该信息被 {{ customer.creator }} 于 {{ customer.add_date }} 创建，被 {{ customer.modifier }} 于 {{ customer.mod_date }} 最后修改。</div>
    </div>
    <br>

    <a class="btn btn-primary" href="/business/mod_customer/{{ customer.name }}" role="button">编辑</a>
    <button id="DeleteCustomer" class="btn btn-primary" href="" role="button">删除</button>
    <a class="btn btn-primary" href="{% url "add_circuit_order" customer.id %}">添加订单</a>

    <script>
        $(function () {
            $("#DeleteCustomer").click(function () {
                if(confirm("确定删除 客户名称: {{ customer.name }} 客户? 该客户的订单和ticket信息也将被一起删除。")){
                    $.get("/business/del_customer?customer_id={{ customer.id }}", function () {
                        window.location.replace("/business");
                    });
                }
            })
        })
    </script>

</div>

<hr>
<h4><strong>关联的订单</strong></h4>
<div class="well well-sm" id="orders_info">
<table class="table table-hover table-condensed table-bordered">
    <thead>
        <tr>
            <td bgcolor="#C9C9C9">订单ID</td>
            <td bgcolor="#C9C9C9">业务类型</td>
            <td bgcolor="#C9C9C9">当前状态</td>
        </tr>
    </thead>
    <tbody>
    {% for order in orders %}
        <tr class="success">
            <td><a href="{% url "show_circuit_order" order.id %}">{{ order.id }}</a></td>
            <td>{{ order.type }}</td>
            <td>{{ order.status }}</td>
        </tr>
    {% endfor %}
    </tbody>
</table>
</div>

<hr>
<h4><strong>关联的Ticket</strong></h4>
<div class="well well-sm" id="tickets_info">
<table class="table table-hover table-condensed table-bordered">
    <thead>
        <tr>
            <td bgcolor="#C9C9C9">Ticket ID</td>
            <td bgcolor="#C9C9C9">关联的订单ID</td>
            <td bgcolor="#C9C9C9">故障级别</td>
            <td bgcolor="#C9C9C9">处理人</td>
            <td bgcolor="#C9C9C9">当前状态</td>
        </tr>
    </thead>
    <tbody>
    {% for ticket in tickets %}
        <tr class="success">
            <td><a href="{% url "show_ticket" ticket.id %}">{{ ticket.id }}</a></td>
            <td>{{ ticket.order_id }}</td>
            <td>{{ ticket.level }}</td>
            <td>{{ ticket.handler }}</td>
            <td>{{ ticket.status }}</td>
        </tr>
    {% endfor %}
    </tbody>
</table>
</div>
{% endblock %}